/*******************************************************************************
 * Copyright (c) 2012 March and Conquest.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package mrusanov.towers.players;

public class Tower implements Cloneable {

	private int wall;
	private int tower;

	public void addToTower(int value) {
		tower += value;
	}

	public void addToWall(int value) {
		wall += value;
	}

	public void damageTower(int value) {
		tower -= value;
		if (tower < 0) {
			tower = 0;
		}
	}

	public void damageWall(int value) {
		wall -= value;

		if (wall < 0) {
			damageTower(-wall);
			wall = 0;
		}
	}

	public int getWallHeight() {
		return wall;
	}

	public void setWallHeight(int wall) {
		this.wall = wall;
	}

	public int getTowerHeight() {
		return tower;
	}

	public void setTowerHeight(int height) {
		tower = height;
	}

	public boolean isAlive() {
		return tower != 0;
	}

	@Override
	public Tower clone() {
		Tower tower = new Tower();
		tower.tower = this.tower;
		tower.wall = wall;
		return tower;
	}

}
